 
 set more off
 cd ""



  ****************************************************************************
  *    WOMEN'S REPRESENTATION & CORRUPTION REPLICATION FILES FOR APPENDIX    *
  ****************************************************************************

  
  /* 
  
  This script replicates appendix materials for the paper on WR and Corruption in Mexico paper
  
  Sections 4, 5, and 8 are available in the R script (Appendix part 1.R)
  
  
  CONTENT:

 
  6) ARE WOMEN MORE LIKELY TO BE AUDITED?
  - Table A3
  
  
  7) ARE AUDITORS HARSHER ON WOMEN?
  - Table A4
  
  
  9-16) OCCURRENCE OF AUDITS AND THE ELECTION OF WOMEN
 - Tables A7-A8
 - Clustered standard errors (Tables A9-A10)
 - Linear probability models (Tables A11-A12)
 - Models with parties (Tables A13-A14)
 - Quota models (Tables A15-A20)
 - Total amount of irregularities (Table A21)
 - Models with at least one woman as candidate (Tables A22-A23)
  
  
  17-22) MODELS FOR SPENDING IRREGULARITIES
 - Measures for skewness (Table A24)
 - Reelection models (Table A25)
 - Quota models (Tables A26-A27)
 - Incumbent party models (Tables A28-A29)
 - Controlling for previous irregularities (Table A30)
 - Only observations with full fund revised (Tables A31)
  

  */
  
  
  
  
  
  ********************************************* 6) ARE WOMEN MORE LIKELY TO BE AUDITED?

   
  use "election_models.dta", clear
  ttest audit_year, by(current_mayor_gender)
  
  
  
  
  
  
  ********************************************* 7) ARE AUDITORS HARSHER ON WOMEN?

  use "spending_irregularities.dta", clear
  ttest sample, by(gender)

  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
 ********************************************* 9-16) OCCURRENCE OF AUDITS AND THE ELECTION OF WOMEN
  
 * IMPORT DATA
 use "election_models.dta", clear

  
 **** Audit occurrence and the election of women (Table A7) 
  
 * Audited (t-1)
 logit elected_mayor_female l_audit_year HDI lpop  i.year i.state_ID if election_year==1  & usos==0,  robust 
 esti store mod1
 
 * Audited (t-2) 
 logit elected_mayor_female l_audit_2yr HDI lpop i.year i.state_ID if election_year==1  & usos==0,  robust 
 esti store mod2

  * Audited (t-3)
 logit elected_mayor_female l_audit_3yr HDI lpop i.year i.state_ID if election_year==1  & usos==0,  robust 
 esti store mod3
 
  * Ever audited
 logit elected_mayor_female l_prev_audits_ever HDI lpop i.year i.state_ID if election_year==1  & usos==0,  robust 
 esti store mod4  
  
  
  ** Regression table (appendix Table A7)
  #delimit ;
  esttab mod1 mod2 mod3 mod4 using table1.rtf, replace 
          title("Audit history and the election of women") addnote("Logistic regressions with cluster standard errors on municipalities") 
          se s(fixed N r2_p, label("N" "R^2$")) 
		  keep(l_audit_year l_audit_2yr  l_audit_3yr l_prev_audits_ever  HDI lpop _cons) label 
          coeflabels(l_audit_year "Audit (t-1)"  l_audit_2yr "Audit (t-2)" 
		  l_audit_3yr "Audit (t-3)" l_prev_audits_ever "Ever audited"
		  HDI "Development index" lpop "Population" _cons "Constant")
		  noabbrev b(%9.2f) star (* 0.1 ** 0.05 *** 0.01) wrap nogap align(c) 
          modelwidth(8) varwidth(20);
 
 
  
  
 **** Revelations of corruption and the election of women (Table A8) 
  
 * Model 1
 logit elected_mayor_female prev_audit_1yr HDI lpop i.year i.state_ID if election_year==1  & usos==0,  robust 
 esti store m1
 
 * Model 2
 logit elected_mayor_female prev_audit_3yr HDI lpop i.year i.state_ID if election_year==1  & usos==0,  robust 
 esti store m2
 
 * Model 3
 logit elected_mayor_female prev_auditreleased_1yr  HDI lpop i.year i.state_ID if election_year==1  & usos==0,  robust 
 esti store m3
 
 * Model 4
 logit elected_mayor_female prev_auditreleased_3yr HDI lpop i.year i.state_ID if election_year==1  & usos==0,  robust 
 esti store m4

  
  ** Regression table (appendix Table A8)
  #delimit ;
  esttab m1 m2 m3 m4 using table1.rtf, replace 
          title("Revelations of corruption and the election of women") addnote("Logistic regressions with robust standard errors") 
          se s(fixed N r2_p, label("N" "R^2$")) 
		  keep(prev_audit_1yr prev_audit_3yr prev_auditreleased_1yr prev_auditreleased_3yr HDI lpop _cons) label 
          coeflabels(prev_audit_1yr "Audit (t-1)" prev_audit_3yr "Audit (t-3)" 
		  prev_auditreleased_1yr "Revelation (t-1)" prev_auditreleased_3yr "Revelation (t-3)"
		  HDI "Development index" lpop "Population" _cons "Constant")
		  noabbrev b(%9.2f) star (* 0.1 ** 0.05 *** 0.01) wrap nogap align(c) 
          modelwidth(8) varwidth(20);
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
 **** CLUSTERED STANDARD ERRORS (Tables A9-A10) 
 
 
 ** Audit occurrence CSE (Table A9)
   
 * Audited (t-1)
 logit elected_mayor_female l_audit_year HDI lpop  i.year i.state_ID if election_year==1  & usos==0,  robust cluster(mun_ID)
 esti store mod1
 
 * Audited (t-2) 
 logit elected_mayor_female l_audit_2yr HDI lpop i.year i.state_ID if election_year==1  & usos==0,  robust cluster(mun_ID)
 esti store mod2

  * Audited (t-3)
 logit elected_mayor_female l_audit_3yr HDI lpop i.year i.state_ID if election_year==1  & usos==0,  robust cluster(mun_ID)
 esti store mod3
 
  * Ever audited
 logit elected_mayor_female l_prev_audits_ever HDI lpop i.year i.state_ID if election_year==1  & usos==0,  robust cluster(mun_ID) 
 esti store mod4  
 
 
   ** Regression table
  #delimit ;
  esttab mod1 mod2 mod3 mod4 using table1.rtf, replace 
          title("Audit history and the election of women") addnote("Logistic regressions with cluster standard errors on municipalities") 
          se s(fixed N r2_p, label("N" "R^2$")) 
		  keep(l_audit_year l_audit_2yr  l_audit_3yr l_prev_audits_ever  HDI lpop _cons) label 
          coeflabels(l_audit_year "Audit (t-1)"  l_audit_2yr "Audit (t-2)" 
		  l_audit_3yr "Audit (t-3)" l_prev_audits_ever "Ever audited"
		  HDI "Development index" lpop "Population" _cons "Constant")
		  noabbrev b(%9.2f) star (* 0.1 ** 0.05 *** 0.01) wrap nogap align(c) 
          modelwidth(8) varwidth(20);
 
 
 
 
 ** Revelations of corruption CSE (Table A10)
 
 * Model 1
 logit elected_mayor_female prev_audit_1yr HDI lpop i.year i.state_ID if election_year==1  & usos==0,  robust cluster(mun_ID)
 esti store m1
 
 * Model 2
 logit elected_mayor_female prev_audit_3yr HDI lpop i.year i.state_ID if election_year==1  & usos==0,  robust cluster(mun_ID)
 esti store m2
 
 * Model 3
 logit elected_mayor_female prev_auditreleased_1yr  HDI lpop i.year i.state_ID if election_year==1  & usos==0,  robust cluster(mun_ID)
 esti store m3
 
 * Model 4
 logit elected_mayor_female prev_auditreleased_3yr HDI lpop i.year i.state_ID if election_year==1  & usos==0,  robust cluster(mun_ID)
 esti store m4
 
  
  
  ** Regression table
  #delimit ;
  esttab m1 m2 m3 m4 using table1.rtf, replace 
          title("Revelations of corruption and the election of women") addnote("Logistic regressions with cluster standard errors on municipalities") 
          se s(fixed N r2_p, label("N" "R^2$")) 
		  keep(prev_audit_1yr prev_audit_3yr prev_auditreleased_1yr prev_auditreleased_3yr HDI lpop _cons) label 
          coeflabels(prev_audit_1yr "Audit (t-1)" prev_audit_3yr "Audit (t-3)" 
		  prev_auditreleased_1yr "Revelation (t-1)" prev_auditreleased_3yr "Revelation (t-3)"
		  HDI "Development index" lpop "Population" _cons "Constant")
		  noabbrev b(%9.2f) star (* 0.1 ** 0.05 *** 0.01) wrap nogap align(c) 
          modelwidth(8) varwidth(20);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
  
  
  
 **** LINEAR PROBABILITY MODELS (Tables A11-A12) 

  
 ** Audit occurrence LMPs (Table A11)
 
 * Audited (t-1)
 reg elected_mayor_female l_audit_year HDI lpop  i.year i.state_ID if election_year==1  & usos==0,  robust 
 esti store mod1
 
 * Audited (t-2) 
 reg elected_mayor_female l_audit_2yr HDI lpop i.year i.state_ID if election_year==1  & usos==0,  robust 
 esti store mod2

  * Audited (t-3)
 reg elected_mayor_female l_audit_3yr HDI lpop i.year i.state_ID if election_year==1  & usos==0,  robust 
 esti store mod3
 
  * Ever audited
 reg elected_mayor_female l_prev_audits_ever HDI lpop i.year i.state_ID if election_year==1  & usos==0,  robust 
 esti store mod4  
 
 
 
   ** Regression table
  #delimit ;
  esttab mod1 mod2 mod3 mod4 using table1.rtf, replace 
          title("Audit history and the election of women") addnote("OLS with robust standard errors on parenthesis") 
          se s(fixed N r2, label("N" "R^2$")) 
		  keep(l_audit_year l_audit_2yr  l_audit_3yr l_prev_audits_ever  HDI lpop _cons) label 
          coeflabels(l_audit_year "Audit (t-1)"  l_audit_2yr "Audit (t-2)" 
		  l_audit_3yr "Audit (t-3)" l_prev_audits_ever "Ever audited"
		  HDI "Development index" lpop "Population" _cons "Constant")
		  noabbrev b(%9.2f) star (* 0.1 ** 0.05 *** 0.01) wrap nogap align(c) 
          modelwidth(8) varwidth(20);
 
 
 

 
 ** Revelations of corruption LMPs (Table A12)
  
 
 * Model 1
 reg elected_mayor_female prev_audit_1yr HDI lpop i.year i.state_ID if election_year==1  & usos==0,  robust 
 esti store m1
 
 * Model 2
 reg elected_mayor_female prev_audit_3yr HDI lpop i.year i.state_ID if election_year==1  & usos==0,  robust 
 esti store m2
 
 * Model 3
 reg elected_mayor_female prev_auditreleased_1yr  HDI lpop i.year i.state_ID if election_year==1  & usos==0,  robust 
 esti store m3
 
 * Model 4
 reg elected_mayor_female prev_auditreleased_3yr HDI lpop i.year i.state_ID if election_year==1  & usos==0,  robust 
 esti store m4
 
  
  
  ** Regression table
  #delimit ;
  esttab m1 m2 m3 m4 using table1.rtf, replace 
          title("Revelations of corruption and the election of women") addnote("OLS with robust standard errors on parenthesis") 
          se s(fixed N r2, label("N" "R^2$")) 
		  keep(prev_audit_1yr prev_audit_3yr prev_auditreleased_1yr prev_auditreleased_3yr HDI lpop _cons) label 
          coeflabels(prev_audit_1yr "Audit (t-1)" prev_audit_3yr "Audit (t-3)" 
		  prev_auditreleased_1yr "Revelation (t-1)" prev_auditreleased_3yr "Revelation (t-3)"
		  HDI "Development index" lpop "Population" _cons "Constant")
		  noabbrev b(%9.2f) star (* 0.1 ** 0.05 *** 0.01) wrap nogap align(c) 
          modelwidth(8) varwidth(20);
 
 
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
 **** MODELS WITH PARTIES (Tables A13-A14) 

  
  * Create numeric party var
  egen party = group(party_winner)
  labmask party, values(party_winner)   
   
        
   
  ** Audit occurence (Table A13)
 
  * Audited (t-1)
  logit elected_mayor_female l_audit_year i.party HDI lpop  i.year i.state_ID if election_year==1  & usos==0,  robust 
  esti store mod1
 
  * Audited (t-2) 
  logit elected_mayor_female l_audit_2yr i.party HDI lpop i.year i.state_ID if election_year==1  & usos==0,  robust 
  esti store mod2

  * Audited (t-3)
  logit elected_mayor_female l_audit_3yr i.party HDI lpop i.year i.state_ID if election_year==1  & usos==0,  robust
  esti store mod3
 
  * Ever audited
  logit elected_mayor_female l_prev_audits_ever i.party HDI lpop i.year i.state_ID if election_year==1  & usos==0,  robust  
  esti store mod4  
 

  
   ** Regression table
  #delimit ;
  esttab mod1 mod2 mod3 mod4 using table1.rtf, replace 
          title("Audit history and the election of women (party models)") addnote("Logistic regressions with robust standard errors on municipalities") 
          se s(fixed N r2_p, label("N" "R^2$")) 
          coeflabels(l_audit_year "Audit (t-1)"  l_audit_2yr "Audit (t-2)" 
		  l_audit_3yr "Audit (t-3)" l_prev_audits_ever "Ever audited"
		  HDI "Development index" lpop "Population" _cons "Constant")
		  noabbrev b(%9.2f) star (* 0.1 ** 0.05 *** 0.01) wrap nogap align(c) 
          modelwidth(8) varwidth(20);
 
 
 
 
  ** Revelations of corruption (Table A14)
 
  * Model 1
  logit elected_mayor_female prev_audit_1yr i.party HDI lpop i.year i.state_ID if election_year==1  & usos==0,  robust 
  esti store m1
 
  * Model 2
  logit elected_mayor_female prev_audit_3yr i.party HDI lpop i.year i.state_ID if election_year==1  & usos==0,  robust 
  esti store m2
 
  * Model 3
  logit elected_mayor_female prev_auditreleased_1yr i.party HDI lpop i.year i.state_ID if election_year==1  & usos==0,  robust
  esti store m3
 
  * Model 4
  logit elected_mayor_female prev_auditreleased_3yr  i.party HDI lpop i.year i.state_ID if election_year==1  & usos==0,  robust 
  esti store m4
 
  
   

  ** Regression table
  #delimit ;
  esttab m1 m2 m3 m4 using table1.rtf, replace 
          title("Revelations of corruption and the election of women (party models)") addnote("Logistic regressions with robust standard errors on municipalities") 
          se s(fixed N r2_p, label("N" "R^2$")) 
          coeflabels(l_audit_year "Audit (t-1)"  l_audit_2yr "Audit (t-2)" 
		  l_audit_3yr "Audit (t-3)" l_prev_audits_ever "Ever audited"
		  HDI "Development index" lpop "Population" _cons "Constant")
		  noabbrev b(%9.2f) star (* 0.1 ** 0.05 *** 0.01) wrap nogap align(c) 
          modelwidth(8) varwidth(20);
 

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
    
  
  
  
 **** QUOTA MODELS (Tables A15-A20)
 
 
 ** Audit occurrence and the election of women: Before quotas (2000-2013) - Table A15
    
 * Audited (t-1)
 logit elected_mayor_female l_audit_year HDI lpop  i.year i.state_ID if election_year==1  & usos==0 & year<2014,  robust
 esti store mod1
 
 * Audited (t-2) 
 logit elected_mayor_female l_audit_2yr HDI lpop i.year i.state_ID if election_year==1  & usos==0  & year<2014,  robust 
 esti store mod2

  * Audited (t-3)
 logit elected_mayor_female l_audit_3yr HDI lpop i.year i.state_ID if election_year==1  & usos==0  & year<2014,  robust 
 esti store mod3
 
  * Ever audited
 logit elected_mayor_female l_prev_audits_ever HDI lpop i.year i.state_ID if election_year==1  & usos==0  & year<2014, robust
 esti store mod4  
 
 
   ** Regression table
  #delimit ;
  esttab mod1 mod2 mod3 mod4 using table1.rtf, replace 
          title("Audit history and the election of women: Before quotas") addnote("Logistic regressions with robust standard errors") 
          se s(fixed N r2_p, label("N" "R^2$")) 
		  keep(l_audit_year l_audit_2yr  l_audit_3yr l_prev_audits_ever  HDI lpop _cons) label 
          coeflabels(l_audit_year "Audit (t-1)"  l_audit_2yr "Audit (t-2)" 
		  l_audit_3yr "Audit (t-3)" l_prev_audits_ever "Ever audited"
		  HDI "Development index" lpop "Population" _cons "Constant")
		  noabbrev b(%9.2f) star (* 0.1 ** 0.05 *** 0.01) wrap nogap align(c) 
          modelwidth(8) varwidth(20);
 
  

 ** Audit occurrence and the election of women: After quotas (2014-2019) - Table A16
  
* Audited (t-1)
 logit elected_mayor_female l_audit_year HDI lpop  i.year i.state_ID if election_year==1  & usos==0 & year>2013,  robust
 esti store mod1
 
 * Audited (t-2) 
 logit elected_mayor_female l_audit_2yr HDI lpop i.year i.state_ID if election_year==1  & usos==0  & year>2013,  robust 
 esti store mod2

  * Audited (t-3)
 logit elected_mayor_female l_audit_3yr HDI lpop i.year i.state_ID if election_year==1  & usos==0  & year>2013,  robust 
 esti store mod3
 
  * Ever audited
 logit elected_mayor_female l_prev_audits_ever HDI lpop i.year i.state_ID if election_year==1  & usos==0  & year>2013, robust
 esti store mod4  
 
 
   ** Regression table
  #delimit ;
  esttab mod1 mod2 mod3 mod4 using table1.rtf, replace 
          title("Audit history and the election of women: After quotas") addnote("Logistic regressions with robust standard errors") 
          se s(fixed N r2_p, label("N" "R^2$")) 
		  keep(l_audit_year l_audit_2yr  l_audit_3yr l_prev_audits_ever  HDI lpop _cons) label 
          coeflabels(l_audit_year "Audit (t-1)"  l_audit_2yr "Audit (t-2)" 
		  l_audit_3yr "Audit (t-3)" l_prev_audits_ever "Ever audited"
		  HDI "Development index" lpop "Population" _cons "Constant")
		  noabbrev b(%9.2f) star (* 0.1 ** 0.05 *** 0.01) wrap nogap align(c) 
          modelwidth(8) varwidth(20);
 
 

  
 ** Audit occurrence and the election of women: Quota interaction models - Table A17
   
 ** Generate interactions
 gen int1 = l_audit_year*parity_req
 gen int2 = l_audit_2yr*parity_req
 gen int3 = l_audit_3yr*parity_req
 gen int4 = l_prev_audits_ever*parity_req
  

* Audited (t-1)
 logit elected_mayor_female int1 l_audit_year parity_req HDI lpop  i.year  if election_year==1  & usos==0,  robust
 esti store mod1
 
 * Audited (t-2) 
 logit elected_mayor_female int2 l_audit_2yr parity_req HDI lpop i.year  if election_year==1  & usos==0,  robust 
 esti store mod2

  * Audited (t-3)
 logit elected_mayor_female int3 l_audit_3yr parity_req HDI lpop i.year  if election_year==1  & usos==0,  robust 
 esti store mod3
 
  * Ever audited
 logit elected_mayor_female int4 l_prev_audits_ever parity_req HDI lpop i.year  if election_year==1  & usos==0, robust
 esti store mod4  
 
 
   ** Regression table
  #delimit ;
  esttab mod1 mod2 mod3 mod4 using table1.rtf, replace 
          title("Audit history and the election of women: quota interactions") addnote("Logistic regressions with robust standard errors") 
          se s(fixed N r2_p, label("N" "R^2$")) 
		  keep(int1 int2 int3 int4 parity_req l_audit_year l_audit_2yr  l_audit_3yr l_prev_audits_ever  HDI lpop _cons) label 
          coeflabels(parity_req "Quota" int1 "Audit (t-1) X Quota" int2 "Audit (t-2) X Quota" 
		  int3 "Audit (t-3) X Quota" int4 "Ever audited X Quota" 
		  l_audit_year "Audit (t-1)"  l_audit_2yr "Audit (t-2)" 
		  l_audit_3yr "Audit (t-3)" l_prev_audits_ever "Ever audited"
		  HDI "Development index" lpop "Population" _cons "Constant")
		  noabbrev b(%9.2f) star (* 0.1 ** 0.05 *** 0.01) wrap nogap align(c) 
          modelwidth(8) varwidth(20);
 
 
  
  
  
  
  
 ** Revelations of corruption and the election of women: Before quotas (2000-2013) - Table A18

 
 * Model 1
 logit elected_mayor_female prev_audit_1yr HDI lpop i.year i.state_ID if election_year==1  & usos==0 & year<2014,  robust 
 esti store m1
 
 * Model 2
 logit elected_mayor_female prev_audit_3yr HDI lpop i.year i.state_ID if election_year==1  & usos==0 & year<2014,  robust 
 esti store m2
 
 * Model 3
 logit elected_mayor_female prev_auditreleased_1yr  HDI lpop i.year i.state_ID if election_year==1  & usos==0 & year<2014,  robust 
 esti store m3
 
 * Model 4
 logit elected_mayor_female prev_auditreleased_3yr HDI lpop i.year i.state_ID if election_year==1  & usos==0 & year<2014,  robust 
 esti store m4
 
  
  
  ** Regression table
  #delimit ;
  esttab m1 m2 m3 m4 using table1.rtf, replace 
          title("Revelations of corruption and the election of women: Before quotas (2000-2013)") addnote("Logistic regressions with robust standard errors on parenthesis") 
          se s(fixed N r2_p, label("N" "R^2$")) 
		  keep(prev_audit_1yr prev_audit_3yr prev_auditreleased_1yr prev_auditreleased_3yr HDI lpop _cons) label 
          coeflabels(prev_audit_1yr "Audit (t-1)" prev_audit_3yr "Audit (t-3)" 
		  prev_auditreleased_1yr "Revelation (t-1)" prev_auditreleased_3yr "Revelation (t-3)"
		  HDI "Development index" lpop "Population" _cons "Constant")
		  noabbrev b(%9.2f) star (* 0.1 ** 0.05 *** 0.01) wrap nogap align(c) 
          modelwidth(8) varwidth(20);
 
 
  
  
 ** Revelations of corruption and the election of women: After quotas (2014-2019) - Table A19
 
 * Model 1
 logit elected_mayor_female prev_audit_1yr HDI lpop i.year i.state_ID if election_year==1  & usos==0 & year>2013,  robust 
 esti store m1
 
 * Model 2
 logit elected_mayor_female prev_audit_3yr HDI lpop i.year i.state_ID if election_year==1  & usos==0 & year>2013,  robust 
 esti store m2
 
 * Model 3
 logit elected_mayor_female prev_auditreleased_1yr  HDI lpop i.year i.state_ID if election_year==1  & usos==0 & year>2013,  robust 
 esti store m3
 
 * Model 4
 logit elected_mayor_female prev_auditreleased_3yr HDI lpop i.year i.state_ID if election_year==1  & usos==0 & year>2013,  robust 
 esti store m4
 
  
  
  ** Regression table
  #delimit ;
  esttab m1 m2 m3 m4 using table1.rtf, replace 
          title("Revelations of corruption and the election of women: After quotas (2014-2019)") addnote("Logistic regressions with robust standard errors on parenthesis") 
          se s(fixed N r2_p, label("N" "R^2$")) 
		  keep(prev_audit_1yr prev_audit_3yr prev_auditreleased_1yr prev_auditreleased_3yr HDI lpop _cons) label 
          coeflabels(prev_audit_1yr "Audit (t-1)" prev_audit_3yr "Audit (t-3)" 
		  prev_auditreleased_1yr "Revelation (t-1)" prev_auditreleased_3yr "Revelation (t-3)"
		  HDI "Development index" lpop "Population" _cons "Constant")
		  noabbrev b(%9.2f) star (* 0.1 ** 0.05 *** 0.01) wrap nogap align(c) 
          modelwidth(8) varwidth(20);
 
  
  
  
 ** Revelations of corruption and the election of women: Interactions - Table A20
  
 * Generate interactions
 drop int*
 gen int1 = prev_audit_1yr*parity_req
 gen int2 = prev_audit_3yr*parity_req
 gen int3 = prev_auditreleased_1yr*parity_req
 gen int4 = prev_auditreleased_3yr*parity_req
   
 * Model 1
 logit elected_mayor_female int1 prev_audit_1yr parity_req HDI lpop i.year  if election_year==1  & usos==0,  robust 
 esti store m1
 
 * Model 2
 logit elected_mayor_female int2 prev_audit_3yr parity_req HDI lpop i.year  if election_year==1  & usos==0,  robust 
 esti store m2
 
 * Model 3
 logit elected_mayor_female int3 prev_auditreleased_1yr  parity_req HDI lpop i.year  if election_year==1  & usos==0,  robust 
 esti store m3
 
 * Model 4
 logit elected_mayor_female int4 prev_auditreleased_3yr parity_req HDI lpop i.year  if election_year==1  & usos==0,  robust 
 esti store m4
 
 
 
   ** Regression table
  #delimit ;
  esttab m1 m2 m3 m4 using table1.rtf, replace 
          title("Revelations of corruption and the election of women: quota interactions") addnote("Logistic regressions with robust standard errors") 
          se s(fixed N r2_p, label("N" "R^2$")) 
		  keep(int1 int2 int3 int4 parity_req prev_audit_1yr prev_audit_3yr prev_auditreleased_1yr prev_auditreleased_3yr  HDI lpop _cons) label 
          coeflabels(parity_req "Quota" int1 "Audit (t-1) X Quota" int2 "Audit (t-3) X Quota" 
		  int3 "Revelation (t-1) X Quota" int4 "Revelation (t-3) X Quota" 
		  prev_audit_1yr "Audit (t-1)" prev_audit_3yr "Audit (t-3)" 
		  prev_auditreleased_1yr "Revelation (t-1)" prev_auditreleased_3yr "Revelation (t-3)"
		  HDI "Development index" lpop "Population" _cons "Constant")
		  noabbrev b(%9.2f) star (* 0.1 ** 0.05 *** 0.01) wrap nogap align(c) 
          modelwidth(8) varwidth(20);
 
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
 **** MODELS WITH AMOUNT OF IRREGULARITIES (Table A21) 
 
  
 ** Create variables:
 
 * Lag irregularities adj
 sort mun_ID year
 gen lag_irreg_adj = .
 by mun_ID: replace lag_irreg_adj = irreg_adj[_n-1]
 
 
 * Largest irreg in the last 3 years
 gen max_irreg_3yr= .
 by mun_ID: replace max_irreg_3yr = max(lag_irreg_adj[_n-1], lag_irreg_adj[_n-2], lag_irreg_adj[_n-3])

 
 * Amount of irreg in the last year or 3 years
 gen irreg_adj_missing = irreg_adj
 replace irreg_adj_missing = . if audit_year==0
 
 sort mun_ID year
 gen irreg_lastyear = .  //amount of irregs found in audit last year
 by mun_ID: replace irreg_lastyear = irreg_adj_missing[_n-1]
 
 gen irreg_last3year= .  //amount of irregs found in an audit conducted in past three years
 by mun_ID: replace irreg_last3year = max(irreg_adj_missing[_n-1], irreg_adj_missing[_n-2], irreg_adj_missing[_n-3])


 
 * Model 1 = Irreg last year
 * Model 2 = Largest irreg in the last 3 years
 * Model 3 = Irreg last year - audited only
 * Model 4 = Largest irreg in the last 3 years - audited only
 
 * Model 1
 logit elected_mayor_female lag_irreg_adj l_audit_year HDI lpop i.state_ID i.year if election_year==1  & usos==0, robust 
 esti store mod1

 * Model 2
 logit elected_mayor_female max_irreg_3yr l_audit_3yr HDI lpop i.state_ID i.year if election_year==1  & usos==0, robust 
 esti store mod2
 
 * Model 3
 logit elected_mayor_female irreg_lastyear  HDI lpop i.state_ID i.year if election_year==1  & usos==0, robust 
 esti store mod3


 * Model 4
 logit elected_mayor_female irreg_last3year HDI lpop parity_req margin i.state_ID i.year if election_year==1  & usos==0, robust 
 esti store mod4
 
  
  ** Regression table
  #delimit ;
  esttab mod1 mod2 mod3 mod4 using table1.rtf, replace 
          title("Amount of irregularities and the election of women") 
		  addnote("Logistic regressions with robust standard errors") 
          se s(fixed N r2_p, label("N" "R^2$")) 
		  keep(lag_irreg_adj l_audit_year max_irreg_3yr
		  l_audit_3yr irreg_lastyear irreg_last3year HDI lpop _cons) label 
          coeflabels(lag_irreg_adj "Irreg (t-1)" l_audit_year "Audit (t-1)" 
		              max_irreg_3yr "Max irreg 3yrs"
		              l_audit_3yr "Audit (t-3)" irreg_lastyear "Irreg (t-1) - audited only" 
		              irreg_last3year "Max irreg 3yrs - audited only"
		              HDI "Development index" lpop "Population" _cons "Constant")
		  noabbrev b(%9.2f) star (* 0.1 ** 0.05 *** 0.01) wrap nogap align(c) 
          modelwidth(8) varwidth(20);
 
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
 **** MODELS WITH AT LEAST ONE WOMAN AS CANDIDATE (Tables A22-A23) 
  
 
  * Import number of women
  use "women_in_election.dta", clear
  
  ** Tempfile
  tempfile cand
  save `cand'
  

  
 ** MERGE WITH ELECTION DATA
 use "election_models.dta", clear
 
 ** Merge
 merge 1:1 cve_inegi year using `cand'
    
 * Keep matched cases
 keep if _merge==3
 drop _merge
 
 
 ** Audit occurrence and the election of women (Table A22)
 
 * Audited (t-1)
 logit elected_mayor_female l_audit_year HDI lpop  i.year i.state_ID if election_year==1  & usos==0 & per_women>0 & per_women<100,  robust 
 esti store mod1
 
 * Audited (t-2) 
 logit elected_mayor_female l_audit_2yr HDI lpop i.year i.state_ID if election_year==1  & usos==0 & per_women>0 & per_women<100,  robust 
 esti store mod2

  * Audited (t-3)
 logit elected_mayor_female l_audit_3yr HDI lpop i.year i.state_ID if election_year==1  & usos==0 & per_women>0 & per_women<100,  robust 
 esti store mod3
 
  * Ever audited
 logit elected_mayor_female l_prev_audits_ever HDI lpop i.year i.state_ID if election_year==1  & usos==0 & per_women>0 & per_women<100,  robust 
 esti store mod4  
 
 
   ** Regression table
  #delimit ;
  esttab mod1 mod2 mod3 mod4 using table1.rtf, replace 
          title("Audit history and the election of women: Mixed gender races") addnote("Logistic regressions with robust standard errors") 
          se s(fixed N r2_p, label("N" "R^2$")) 
		  keep(l_audit_year l_audit_2yr  l_audit_3yr l_prev_audits_ever  HDI lpop _cons) label 
          coeflabels(l_audit_year "Audit (t-1)"  l_audit_2yr "Audit (t-2)" 
		  l_audit_3yr "Audit (t-3)" l_prev_audits_ever "Ever audited"
		  HDI "Development index" lpop "Population" _cons "Constant")
		  noabbrev b(%9.2f) star (* 0.1 ** 0.05 *** 0.01) wrap nogap align(c) 
          modelwidth(8) varwidth(20);
 

 
 ** Revelations of corruption and the election of women (Table A23)
  
 * Model 1
 logit elected_mayor_female prev_audit_1yr HDI lpop i.year i.state_ID if election_year==1  & usos==0 & per_women>0 & per_women<100,  robust 
 esti store m1
 
 * Model 2
 logit elected_mayor_female prev_audit_3yr HDI lpop i.year i.state_ID if election_year==1  & usos==0 & per_women>0 & per_women<100,  robust 
 esti store m2
 
 * Model 3
 logit elected_mayor_female prev_auditreleased_1yr  HDI lpop i.year i.state_ID if election_year==1  & usos==0 & per_women>0 & per_women<100,  robust 
 esti store m3
 
 * Model 4
 logit elected_mayor_female prev_auditreleased_3yr HDI lpop i.year i.state_ID if election_year==1  & usos==0 & per_women>0 & per_women<100,  robust 
 esti store m4
  
  
  ** Regression table
  #delimit ;
  esttab m1 m2 m3 m4 using table1.rtf, replace 
          title("Revelations of corruption and the election of women: Mixed gender races") addnote("Logistic regressions with robust standard errors") 
          se s(fixed N r2_p, label("N" "R^2$")) 
		  keep(prev_audit_1yr prev_audit_3yr prev_auditreleased_1yr prev_auditreleased_3yr HDI lpop _cons) label 
          coeflabels(prev_audit_1yr "Audit (t-1)" prev_audit_3yr "Audit (t-3)" 
		  prev_auditreleased_1yr "Revelation (t-1)" prev_auditreleased_3yr "Revelation (t-3)"
		  HDI "Development index" lpop "Population" _cons "Constant")
		  noabbrev b(%9.2f) star (* 0.1 ** 0.05 *** 0.01) wrap nogap align(c) 
          modelwidth(8) varwidth(20);
 
 

  

  
  
  
  
  
  
  
  
  
 
 
 
  
  

   
   
  
  
  
  
  
  
  
  
 ********************************************* 17-22) MODELS FOR SPENDING IRREGULARITIES

 
 
 
 
  
 **** MODELS WITH MEASURES FOR SWEKNESS (Table A24) 
  
  
  ** Import data
  use "spending_irregularities.dta", clear
    
  
  * Model 1 <300,000
  reg irreg_adj gender HDI lpop universe_adj l_prevaudits i.state_ID i.year if irreg_adj < 300000, robust
  esti store mod1 
  
  * Model 2 <200,000
  reg irreg_adj gender HDI lpop universe_adj l_prevaudits i.state_ID i.year if irreg_adj < 200000, robust
  esti store mod2 
  
  * Model 3 < 150,000
  reg irreg_adj gender HDI lpop universe_adj l_prevaudits i.state_ID i.year if irreg_adj < 150000, robust
  esti store mod3 
    
  * LOG
  reg ln1_irreg_adj gender HDI lpop universe_adj l_prevaudits i.state_ID i.year, robust
  esti store mod4 
  
  
  * SRQT
  reg irreg_sqrt gender HDI lpop universe_adj l_prevaudits i.state_ID i.year, robust
  esti store mod5 
	
  
  ** Regression table
  #delimit ;
  esttab mod1 mod2 mod3 mod4 mod5 using table1.rtf, replace 
          title("Reported irregularities and gender of the mayor") addnote("OLS regressions with robust standard errors in parenthesis") 
          se s(fixed N r2, label("N" "R^2$")) 
          keep(gender HDI lpop universe_adj l_prevaudits _cons) label
          coeflabels(gender "Female" l_prevaudits "Previous audits" 
		  HDI "Development index" lpop "Log population" universe_adj "Resources" 
		   _cons "Constant") 
		  noabbrev b(%9.2f) star (* 0.1 ** 0.05 *** 0.01) wrap nogap align(c) 
          modelwidth(8) varwidth(20);
 

  
  
  
  
  
  
  
  
  
  
  
  
  
  **** REELECTION MODELS (Table A25) 

  ** Import reelection subset
  use "reelection_DID_subset.dta", clear
   
  * Interaction (treatment group X period)
  gen did = treat_16*period
  
  reg irreg_adj did treat_16 period i.state if gender==1, robust
  esti store women

  reg irreg_adj did treat_16 period i.state if gender==0, robust
  esti store men
 
 
   ** Regression table
  #delimit ;
  esttab women men using table1.rtf, replace 
          title("Difference-in-difference models") addnote("OLS with robust standard errors in parenthesis") 
          se s(fixed N r2, label("N" "R^2$")) 
          keep(did treat_16 period  _cons) label
          coeflabels(did "Reelection X Period" treat_16 "Reelection" period "Period") 
		  noabbrev b(%9.2f) star (* 0.1 ** 0.05 *** 0.01) wrap nogap align(c) 
          modelwidth(8) varwidth(20);
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  **** QUOTA MODELS (Tables A26-A27) 

  
  ** Before and after quotas (Table A26)
  use "spending_irregularities.dta", clear

  * Pre-quota
  reg irreg_adj gender HDI lpop universe_adj l_prevaudits i.state_ID i.year if year<2014, robust
  esti store mod1 
  
  
  * Pre-quota (log)
  reg ln1_irreg_adj gender HDI lpop universe_adj l_prevaudits i.state_ID if year<2014, robust
  esti store mod2 
  
  
  * Post-quota
  reg irreg_adj gender HDI lpop universe_adj l_prevaudits i.state_ID i.year if year>2013, robust
  esti store mod3 
  
  
  * Post-quota (log)
  reg ln1_irreg_adj gender HDI lpop universe_adj l_prevaudits i.state_ID i.year if year>2013, robust
  esti store mod4 
	
  
  ** Regression table
  #delimit ;
  esttab mod1 mod2 mod3 mod4 using table1.rtf, replace 
          title("Reported irregularities and gender of the mayor: pre-post quotas") addnote("OLS regressions with robust standard errors in parenthesis") 
          se s(fixed N r2, label("N" "R^2$")) 
          keep(gender HDI lpop universe_adj l_prevaudits _cons) label
          coeflabels(gender "Female" l_prevaudits "Previous audits" 
		  HDI "Development index" lpop "Log population" universe_adj "Resources" 
		   _cons "Constant") 
		  noabbrev b(%9.2f) star (* 0.1 ** 0.05 *** 0.01) wrap nogap align(c) 
          modelwidth(8) varwidth(20);
 



  ** Quota interactions (Table A27)
  
  
  * Create interaction 
  gen int1 = gender*parity_req
   
  * Model 1
  reg irreg_adj int1 gender parity_req HDI lpop universe_adj l_prevaudits i.year, robust
  esti store mod1 
  
  
  * Model 2
  reg ln1_irreg_adj int1 gender parity_req HDI lpop universe_adj l_prevaudits i.year, robust
  esti store mod2 
    

   ** Regression table
  #delimit ;
  esttab mod1 mod2 using table1.rtf, replace 
          title("Reported irregularities and gender of the mayor: quota interactions") addnote("OLS regressions with robust standard errors in parenthesis") 
          se s(fixed N r2, label("N" "R^2$")) 
          keep(int1 gender parity_req HDI lpop universe_adj l_prevaudits _cons) label
          coeflabels(int1 "Female X Quota" gender "Female" parity_req "Quota" l_prevaudits "Previous audits" 
		  HDI "Development index" lpop "Log population" universe_adj "Resources" 
		   _cons "Constant") 
		  noabbrev b(%9.2f) star (* 0.1 ** 0.05 *** 0.01) wrap nogap align(c) 
          modelwidth(8) varwidth(20);
 
 

 
 
 
 
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  **** INCUMBENT PARTY MODELS (Tables A28-A29) 
  
  
  ** Revelations of corruption and the election of women: Incumbent party interaction (Table A28)
  
  * Import elections data
  use "election_models.dta", clear

  * Generate interaction (Incumbent X Audits)
  gen int1 = prev_auditreleased_1yr*incumbent
  gen int2 = prev_auditreleased_3yr*incumbent
  
  * Model 1
  logit elected_mayor_female int1 prev_auditreleased_1yr incumbent HDI lpop i.year i.state_ID if election_year==1  & usos==0,  robust  
  esti store mod1
  
  * Model 2
  logit elected_mayor_female int2 prev_auditreleased_3yr incumbent HDI lpop i.year i.state_ID if election_year==1  & usos==0,  robust  
  esti store mod2
  
    
  ** Regression table
  #delimit ;
  esttab mod1 mod2 using table1.rtf, replace 
          title("Revelations of corruption and the election of women: Incumbent party interaction") addnote("Logistic regressions with robust standard errors") 
          se s(fixed N r2_p, label("N" "R^2$")) 
		  keep(int1 int2 incumbent prev_auditreleased_1yr prev_auditreleased_3yr HDI lpop _cons) label 
          coeflabels(int1 "Revelation (t-1) X Incumbent" int2 "Revelation (t-3) X Incumbent" incumbent "Incumbent" 
		  prev_auditreleased_1yr "Revelation (t-1)" prev_auditreleased_3yr "Revelation (t-3)"
		  HDI "Development index" lpop "Population" _cons "Constant")
		  noabbrev b(%9.2f) star (* 0.1 ** 0.05 *** 0.01) wrap nogap align(c) 
          modelwidth(8) varwidth(20);
 
 
  
  
  ** Irregularities and gender of the mayor: incumbent party models (Table A29)

  * Import data
  use "spending_irregularities.dta", clear

  
  * Incumbent party interaction
  gen int1 = gender*incumbent
  
  * PRI as baseline category

  * Model 1
  reg irreg_adj gender ib1.party i.state_ID i.year, robust 
  esti store mod1 
  
  * Model 2
  reg irreg_adj gender ib1.party  HDI lpop universe_adj l_prevaudits i.state_ID i.year, robust
  esti store mod2 
  
  * Model 3
  reg irreg_adj gender ib1.party  HDI lpop universe_adj l_prevaudits i.state_ID i.year if irreg_adj~=0, robust
  esti store mod3 
  
  
  * Model 4
  reg ln1_irreg_adj gender ib1.party  HDI lpop universe_adj l_prevaudits i.state_ID i.year, robust
  esti store mod4 
  
  
  * Model 5
  reg irreg_adj gender##incumbent HDI lpop universe_adj l_prevaudits i.state_ID i.year, robust
  reg irreg_adj int1 gender incumbent HDI lpop universe_adj l_prevaudits i.state_ID i.year, robust
  esti store mod5 
	
	
  reg irreg_adj gender##incumbent HDI lpop universe_adj l_prevaudits i.state_ID i.year, robust  	
  margins gender##incumbent, atmeans 
  margins incumbent, at(gender=(0(1)1))

  
  ** Marginsplot (Figure A2)
  #delimit ;

    mplotoffset, recast(scatter) recastci(rspike) plotopts(msize(small)) 
	             offset(0.1) xlab(-1(1)2, nogrid labsize(small)) 
				 ylab(0(5000)20000, nogrid)
				 legend(order(1 "Opposition" 2 "Incumbent") cols(1) pos(3))
		         ytitle("Irregularities (thousands of pesos)") title("")
	             xtitle("") title("")
				 graphregion(color(white)) bgcolor(white)
				 xtitle("") name(g2, replace);	
  

  ** Regression table
  #delimit ;
  esttab mod1 mod2 mod3 mod4 mod5 using table1.rtf, replace 
          title("Reported irregularities and gender of the mayor: Party models") addnote("OLS regressions with robust standard errors in parenthesis") 
          se s(fixed N r2, label("N" "R^2$")) 
          coeflabels(int1 "Woman X Incumbent" gender "Woman" incumbent "Incumbent" l_prevaudits "Previous audits" 
		  HDI "Development index" lpop "Log population" universe_adj "Resources" 
		   _cons "Constant") 
		  noabbrev b(%9.2f) star (* 0.1 ** 0.05 *** 0.01) wrap nogap align(c) 
          modelwidth(8) varwidth(20);
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
   **** CONTROLLING FOR PREVIOUS IRREGULARITIES (Table A30) 

 
  * Model 1
  reg irreg_adj gender l_irreg_adj i.state_ID i.year, robust 
  esti store mod1 
    
  
  * Model 2
  reg irreg_adj gender l_irreg_adj HDI lpop universe_adj l_prevaudits i.state_ID i.year, robust
  esti store mod2 
  
  * Model 3
  reg irreg_adj gender l_irreg_adj HDI lpop universe_adj l_prevaudits i.state_ID i.year if irreg_adj~=0, robust
  esti store mod3 
  
  
  * Model 4
  reg ln1_irreg_adj gender l_irreg_adj HDI lpop universe_adj l_prevaudits i.state_ID i.year, robust
  esti store mod4 
   
   
   ** Regression table
   #delimit ;
   esttab mod1 mod2 mod3 mod4 using table1.rtf, replace 
          title("Models controlling for previous irregularities") addnote("OLS with robust standard errors in parenthesis") 
          se s(fixed N r2, label("N" "R^2$")) 
          keep(gender l_irreg_adj HDI lpop universe_adj l_prevaudits  _cons) label
          coeflabels(gender "Female" l_irreg_adj "Irregularities (lag)" l_prevaudits "Previous audits" 
		  HDI "Development index" lpop "Log population" universe_adj "Resources" 
		   _cons "Constant") 
		  noabbrev b(%9.2f) star (* 0.1 ** 0.05 *** 0.01) wrap nogap align(c) 
          modelwidth(8) varwidth(20);
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
  **** FULLY AUDITED SAMPLE MODELS (Table A31)
 
  
  * Model 1 
  quietly reg irreg_adj gender i.state_ID i.year if sample==100, robust 
  esti store mod1 
  
  * Model 2
  quietly reg irreg_adj gender HDI lpop universe_adj l_prevaudits i.state_ID i.year if sample==100, robust
  esti store mod2 
  
  * Model 3
  quietly reg irreg_adj gender HDI lpop universe_adj l_prevaudits i.state_ID i.year if sample==100 & irreg_adj~=0, robust
  esti store mod3 
  
  
  * Model 4
  quietly reg ln1_irreg_adj gender HDI lpop universe_adj l_prevaudits i.state_ID i.year if sample==100, robust
  esti store mod4 

  
  ** Regression table
  #delimit ;
  esttab mod1 mod2 mod3 mod4 using table1.rtf, replace 
          title("Reported irregularities and gender of the mayor (100% of the fund audited)") addnote("Logistic regressions with robust standard errors in parenthesis") 
          se s(fixed N r2, label("N" "R^2$")) 
          keep(gender HDI lpop universe_adj l_prevaudits _cons) label
          coeflabels(gender "Female" l_prevaudits "Previous audits" 
		  HDI "Development index" lpop "Log population" universe_adj "Resources" 
		   _cons "Constant") 
		  noabbrev b(%9.2f) star (* 0.1 ** 0.05 *** 0.01) wrap nogap align(c) 
          modelwidth(8) varwidth(20);
 
 
 
 
 
  
  
 
 
 
   
 
